// Copyright (c)  YISH. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;

namespace NSQL
{
    public class Table : ITable
    {
        public Identifier Alias { get; set; }
        public Identifier Name { get; set; }
        public Identifier Schema { get; set; }
        public Table(string name, string schema = null)
        {
            Name = name;
            Schema = schema;
        }

        public bool IsDual =>
            Schema == null && Alias == null &&
            string.Equals("dual", Name, StringComparison.OrdinalIgnoreCase);

        public object DeepCopy()
        {
            return new Table(Name, Schema)
            {
                Alias = Alias,
                Tag = Tag
            };
        }

        public object Tag { get; set; }
        
        
        public static implicit operator Table(string name) => new Table(name);
    }
}